import 'package:json_annotation/json_annotation.dart';

part 'pay_qr_code.g.dart';

@JsonSerializable()
class PayQrCode extends Object {
  @JsonKey(name: 'applyType')
  int applyType;

  @JsonKey(name: 'batchId')
  int batchId;

  @JsonKey(name: 'binder')
  int binder;

  @JsonKey(name: 'btime')
  String btime;

  @JsonKey(name: 'creator')
  int creator;

  @JsonKey(name: 'ctime')
  String ctime;

  @JsonKey(name: 'del')
  int del;

  @JsonKey(name: 'describe')
  String describe;

  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'pushType')
  int pushType;

  @JsonKey(name: 'qrcode')
  String qrcode;

  @JsonKey(name: 'qrcodeUrl')
  String qrcodeUrl;

  @JsonKey(name: 'status')
  int status;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'updater')
  int updater;

  @JsonKey(name: 'utime')
  String utime;

  String get applyTypeText {
    final map = {
      0: '未绑定',
      1: '扫码绑定',
      2: '自助申请',
    };

    return map[applyType];
  }

  PayQrCode({
    this.applyType,
    this.batchId,
    this.binder,
    this.btime,
    this.creator,
    this.ctime,
    this.del,
    this.describe,
    this.id,
    this.pushType,
    this.qrcode,
    this.qrcodeUrl,
    this.status,
    this.storeId,
    this.updater,
    this.utime,
  });

  factory PayQrCode.fromJson(Map<String, dynamic> srcJson) => _$PayQrCodeFromJson(srcJson);

  Map<String, dynamic> toJson() => _$PayQrCodeToJson(this);
}

@JsonSerializable()
class PayQrCodePage extends Object {
  @JsonKey(name: 'total')
  int total;

  @JsonKey(name: 'totalPage')
  int totalPage;

  @JsonKey(name: 'items')
  List<PayQrCode> items;

  PayQrCodePage(
    this.total,
    this.totalPage,
    this.items,
  );

  factory PayQrCodePage.fromJson(Map<String, dynamic> srcJson) => _$PayQrCodePageFromJson(srcJson);

  Map<String, dynamic> toJson() => _$PayQrCodePageToJson(this);
}
